{include file="../public/static/html/header.html"}
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 课程管理 <span class="c-gray en">&gt;</span> 课程列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20"><span class="r">共有数据：<strong>{$count}</strong> 条</span></div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
			<thead>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th width="80">ID</th>
					<th width="50">课程姓名</th>
					<th width="50">课程类别</th>
					<th width="80">课程教师</th>
					<th width="80">关注人数</th>
					<th width="50">人气数</th>
				    <th width="50">是否精选</th>
					<th width="60">创建时间</th>
					<th width="120">操作</th>
				</tr>
			</thead>
			<tbody>
			{volist name="list" id="vo"}
				<tr class="text-c">
					<td><input type="checkbox" value="{$vo.room_id}" name="{$vo.room_id}"></td>
					<td>{$vo.room_id}</td>
					<td>{$vo.title}</td>
					<td>{$vo.room_stype}</td>
					<td>{$vo.teachername}</td>
					<td>{$vo.center_num}</td>
					<td>{$vo.popul_num}</td>
					<td>{$vo.is_good|is_good}</td>	
					<td>{$vo.create_time|date="Y-m-d",###}</td>
					<td class="f-14 td-manage"><a style="text-decoration:none" onClick="examine_pass(this)" name="{$vo.room_id}" href="javascript:;" title="升级成为精选">
						<i class="Hui-iconfont">&#xe6e1;</i>
						</a> 
						<a style="text-decoration:none" class="ml-5" onClick="examine_stop(this)" name="{$vo.room_id}" href="javascript:;" title="去除精选">
						<i class="Hui-iconfont">&#xe6dd;</i>
						</a>
						<a style="text-decoration:none" class="ml-5" onClick="delete_room(this)" name="{$vo.room_id}" href="javascript:;" title="删除课程">
						<i class="Hui-iconfont">&#xe609;</i>
						</a>  
					</td>
				</tr>
			 {/volist}
			</tbody>
		</table>
	</div>
</div>
{include file="../public/static/html/last.html"}
<script type="text/javascript">
$('.table-sort').dataTable({
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"pading":false,
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,8]}// 不参与排序的列
	]
});

/*升级课程为精选课程*/
function examine_pass(obj){
    var data={};
    var url="/admin/room/examine_pass";
    data['room_id']=$(obj).attr('name');
    var jinxuan=$(obj).parent().parent().children().get(0);
    var jinxuan1=$(jinxuan).next().next().next().next().next().next().next();
    $.post(url,data,function (res) {
		if(res.code==1)
		{
		     dialog.suc_ok('操作成功!');
		     $(jinxuan1).text("是");
		     $(jinxuan1).css('color','green');
		}
		else if(res.code==0)
		{
		    dialog.error_ok('操作失败!!请重新操作');
		}
    },"JSON");

}
/*精选课程-去掉精选*/
function examine_stop(obj){
    var data={};
    var url="/admin/room/examine_stop";
    var jinxuan=$(obj).parent().parent().children().get(0);
    var jinxuan1=$(jinxuan).next().next().next().next().next().next().next();
    data['room_id']=$(obj).attr('name');
    $.post(url,data,function (res) {
        if(res.code==1)
        {
            dialog.suc_ok('操作成功!');
            $(jinxuan1).text("否");
            $(jinxuan1).css('color','#333');
        }
        else if(res.code==0)
        {
            dialog.error_ok('操作失败!!请重新操作');
        }
    },"JSON");

}
/*删除课程*/
function delete_room(obj)
{
    	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '/admin/room/delete_room?id='+$(obj).attr('name'),
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
</script> 
</body>
</html>